package ch.usi.inf.pf2.editor;

import java.awt.Color;

import javax.swing.BorderFactory;
import javax.swing.border.EtchedBorder;

import ch.usi.inf.pf2.Sheet;
import ch.usi.inf.pf2.cell.Cell;
import junit.framework.TestCase;
/**
 * 
 * @author Lorenzo Baracchi <lorenzo.baracchi@usi.ch>
 *
 */
public class TestChangeCellBorder extends TestCase
{
    private Sheet s;
    private Cell c;
    private ChangeCellBorder chcb;
    
    protected void setUp()
    {
	   s= new Sheet();
	   s.initializeSheet();
	   c=s.getCell(1, 1);
	   c.setBorderType(BorderFactory.createEtchedBorder(EtchedBorder.RAISED));
	   chcb = new ChangeCellBorder(s, 1, 1, BorderFactory.createLineBorder(Color.BLACK));
    }
    
    public void testEvaluate ()
    {
	   chcb.evaluate();
	   assertEquals(BorderFactory.createEtchedBorder(EtchedBorder.RAISED), chcb.getOldBorder());
	   assertEquals(BorderFactory.createLineBorder(Color.BLACK), chcb.getNewBorder());
	   assertEquals(BorderFactory.createLineBorder(Color.BLACK), c.getBorderType());
    }
    
    public void testRestore ()
    {
	   chcb.evaluate();
	   chcb.restore();
	   assertEquals(BorderFactory.createEtchedBorder(EtchedBorder.RAISED), chcb.getOldBorder());
	   assertEquals(BorderFactory.createLineBorder(Color.BLACK), chcb.getNewBorder());
	   assertEquals(BorderFactory.createEtchedBorder(EtchedBorder.RAISED), c.getBorderType());
    }
}
